package com.example.transfer2;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

public class PcFtpconnect extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_pc_ftpconnect);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.pc_ftpconnect, menu);
		return true;
	}
	
	public void DisconnectFTP(View view){
		transferfileClient.disconnect();
		System.exit(1);
	}
	
	public void GetFile(View view){
		TextView txtfile;
		txtfile = (EditText)findViewById(R.id.txtfile);
		String Filename = txtfile.getText().toString();
		try {
			boolean filereceived = transferfileClient.ReceiveFile(Filename);
			if(filereceived){txtfile.setText("Received successfully");}
			else {txtfile.setText("Receive failed");}
		} catch (Exception e) {
			txtfile.setText("Receive failed");
			e.printStackTrace();
		}
	}
	
	public void SendFile(View view){
		TextView txtfile;
		txtfile = (EditText)findViewById(R.id.txtfile);
		String Filename = txtfile.getText().toString();
		try {
			boolean filereceived = transferfileClient.SendFile(Filename);
			if(filereceived){txtfile.setText("Sent successfully");}
			else {txtfile.setText("Send failed");}
		} catch (Exception e) {
			txtfile.setText("Send failed");
			e.printStackTrace();
		}
	}

}
